from django.shortcuts import render
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

# Create your views here.
RES = {
    "code": "0001",
    "success": True,
    "msg": "login success"
}


class ApiCaseView(GenericViewSet):
    authentication_classes = ()
    permission_classes = ()

    def less_than(self, request,**kwargs):
        """

        :return:
        """
        data=int(request.query_params['data'])
        RES['data'] = data-1
        RES['msg']=self.less_than.__name__
        return Response(RES)

    def less_than_or_equals(self, request,**kwargs):
        """

        :return:
        """
        data=int(request.query_params['data'])
        RES['data'] = data-1
        RES['data2'] = data
        RES['msg']=self.less_than_or_equals.__name__
        return Response(RES)

    def greater_than(self, request,**kwargs):
        """

        :return:
        """
        data=int(request.query_params['data'])
        RES['data'] = data+1
        RES['msg']=self.greater_than.__name__
        return Response(RES)

    def greater_than_or_equals(self, request,**kwargs):
        """

        :return:
        """
        data=int(request.query_params['data'])
        RES['data'] = data+1
        RES['data2'] = data
        RES['msg']=self.greater_than_or_equals.__name__
        return Response(RES)

    def not_equals(self, request,**kwargs):
        """

        :return:
        """
        data=int(request.query_params['data'])
        RES['data'] = data+1
        RES['msg']=self.not_equals.__name__
        return Response(RES)
